<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${post.spec.title + ' - ' + theme.config.basic.site_title}">产品详情</title>
    <meta name="description" th:content="${post.status.excerpt != null ? post.status.excerpt : '专业机械设备产品详情'}">
    <meta name="keywords" content="机械设备,工业制造,外贸,产品详情">
</head>
<body>
<th:block th:replace="~{layout :: content}">
    
    <!-- 面包屑导航 -->
    <section class="breadcrumb-section">
        <div class="container">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="/">首页</a></li>
                    <li class="breadcrumb-item"><a href="/archives">产品中心</a></li>
                    <li class="breadcrumb-item" th:if="${post.categories != null && !post.categories.empty}">
                        <a th:href="'/categories/' + ${post.categories[0].metadata.name}" th:text="${post.categories[0].spec.displayName}">产品分类</a>
                    </li>
                    <li class="breadcrumb-item active" th:text="${post.spec.title}">产品名称</li>
                </ol>
            </nav>
        </div>
    </section>

    <!-- 产品详情主体 -->
    <section class="product-detail-main">
        <div class="container">
            <div class="product-detail-wrapper">
                <!-- 产品图片画廊 -->
                <div class="product-gallery-section">
                    <div class="product-gallery">
                        <!-- 主图显示区 -->
                        <div class="main-image-container">
                            <div class="main-image-wrapper">
                                <img th:if="${post.spec.cover != null}" th:src="${post.spec.cover}" th:alt="${post.spec.title}" id="mainProductImage" class="main-product-image">
                                <img th:if="${post.spec.cover == null}" src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20professional%20product%20photo%20on%20white%20background&image_size=square_hd" th:alt="${post.spec.title}" id="mainProductImage" class="main-product-image">
                                <div class="image-zoom-overlay">
                                    <i class="fas fa-search-plus"></i>
                                </div>
                            </div>
                            <!-- 图片导航按钮 -->
                            <button class="gallery-nav prev-btn" onclick="previousImage()">
                                <i class="fas fa-chevron-left"></i>
                            </button>
                            <button class="gallery-nav next-btn" onclick="nextImage()">
                                <i class="fas fa-chevron-right"></i>
                            </button>
                        </div>
                        
                        <!-- 缩略图列表 -->
                        <div class="thumbnail-gallery">
                            <div class="thumbnail-container">
                                <div class="thumbnail-item active" onclick="changeMainImage(this, 0)">
                                    <img th:if="${post.spec.cover != null}" th:src="${post.spec.cover}" th:alt="${post.spec.title}">
                                    <img th:if="${post.spec.cover == null}" src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20professional%20product%20photo%20on%20white%20background&image_size=square" th:alt="${post.spec.title}">
                                </div>
                                <div class="thumbnail-item" onclick="changeMainImage(this, 1)">
                                    <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20side%20view%20professional%20product%20photo&image_size=square" alt="产品侧视图">
                                </div>
                                <div class="thumbnail-item" onclick="changeMainImage(this, 2)">
                                    <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20detail%20close%20up%20professional%20photo&image_size=square" alt="产品细节图">
                                </div>
                                <div class="thumbnail-item" onclick="changeMainImage(this, 3)">
                                    <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20application%20scene%20factory%20environment&image_size=square" alt="应用场景">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 产品信息区 -->
                <div class="product-info-section">
                    <div class="product-header">
                        <h1 class="product-title" th:text="${post.spec.title}">产品名称</h1>
                        <div class="product-badges">
                            <span class="badge badge-quality">优质产品</span>
                            <span class="badge badge-export">出口品质</span>
                            <span class="badge badge-cert">ISO认证</span>
                        </div>
                    </div>
                    
                    <div class="product-meta-info">
                        <div class="meta-item">
                            <span class="meta-label">产品编号:</span>
                            <span class="meta-value" th:text="${post.metadata.product_code != null ? post.metadata.product_code : 'MC-' + T(java.lang.System).currentTimeMillis()}">MC-001</span>
                        </div>
                        <div class="meta-item">
                            <span class="meta-label">产品分类:</span>
                            <span class="meta-value" th:text="${post.categories != null && !post.categories.empty ? post.categories[0].spec.displayName : '机械设备'}">机械设备</span>
                        </div>
                        <div class="meta-item">
                            <span class="meta-label">发布时间:</span>
                            <span class="meta-value" th:text="${#temporals.format(post.spec.publishTime, 'yyyy-MM-dd')}">2024-01-01</span>
                        </div>
                    </div>

                    <div class="product-summary">
                        <h3>产品概述</h3>
                        <p th:text="${post.status.excerpt != null ? post.status.excerpt : '专业机械设备，采用先进工艺制造，品质可靠，性能优异，广泛应用于工业制造领域。'}">产品简短描述</p>
                    </div>

                    <!-- 核心特点 -->
                    <div class="product-highlights">
                        <h3>核心特点</h3>
                        <div class="highlights-grid">
                            <div class="highlight-item">
                                <i class="fas fa-award"></i>
                                <div class="highlight-content">
                                    <h4>优质材料</h4>
                                    <p>采用高品质原材料制造</p>
                                </div>
                            </div>
                            <div class="highlight-item">
                                <i class="fas fa-cogs"></i>
                                <div class="highlight-content">
                                    <h4>精密工艺</h4>
                                    <p>先进的生产工艺和技术</p>
                                </div>
                            </div>
                            <div class="highlight-item">
                                <i class="fas fa-shield-alt"></i>
                                <div class="highlight-content">
                                    <h4>质量保证</h4>
                                    <p>严格的质量控制体系</p>
                                </div>
                            </div>
                            <div class="highlight-item">
                                <i class="fas fa-shipping-fast"></i>
                                <div class="highlight-content">
                                    <h4>快速交付</h4>
                                    <p>高效的生产和物流体系</p>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 询价和联系 -->
                    <div class="product-actions">
                        <div class="action-buttons">
                            <button class="btn btn-primary btn-lg" onclick="openInquiryModal()">
                                <i class="fas fa-envelope"></i>
                                立即询价
                            </button>
                            <a th:href="'tel:' + ${theme.config.basic.contact_phone}" class="btn btn-outline btn-lg">
                                <i class="fas fa-phone"></i>
                                电话咨询
                            </a>
                            <button class="btn btn-secondary" onclick="addToFavorites()">
                                <i class="far fa-heart"></i>
                                收藏
                            </button>
                        </div>
                        
                        <div class="contact-info">
                            <div class="contact-item">
                                <i class="fas fa-envelope"></i>
                                <span th:text="${theme.config.basic.contact_email}">info@company.com</span>
                            </div>
                            <div class="contact-item">
                                <i class="fas fa-phone"></i>
                                <span th:text="${theme.config.basic.contact_phone}">+86-400-123-4567</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 产品详细信息标签页 -->
    <section class="product-details-tabs">
        <div class="container">
            <div class="tabs-container">
                <div class="tab-navigation">
                    <button class="tab-btn active" onclick="switchTab('description')">产品描述</button>
                    <button class="tab-btn" onclick="switchTab('specifications')">技术规格</button>
                    <button class="tab-btn" onclick="switchTab('applications')">应用领域</button>
                    <button class="tab-btn" onclick="switchTab('certifications')">认证资质</button>
                </div>
                
                <div class="tab-content-container">
                    <!-- 产品描述 -->
                    <div class="tab-content active" id="description">
                        <div class="content-wrapper">
                            <div th:utext="${post.content.content}">产品详细描述内容</div>
                        </div>
                    </div>
                    
                    <!-- 技术规格 -->
                    <div class="tab-content" id="specifications">
                        <div class="content-wrapper">
                            <div class="specifications-table">
                                <table class="spec-table">
                                    <thead>
                                        <tr>
                                            <th>技术参数</th>
                                            <th>规格值</th>
                                            <th>单位</th>
                                            <th>备注</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>材质</td>
                                            <td th:text="${post.metadata.material != null ? post.metadata.material : '高强度合金钢'}">高强度合金钢</td>
                                            <td>-</td>
                                            <td>符合国际标准</td>
                                        </tr>
                                        <tr>
                                            <td>外形尺寸</td>
                                            <td th:text="${post.metadata.dimensions != null ? post.metadata.dimensions : '1200×800×600'}">1200×800×600</td>
                                            <td>mm</td>
                                            <td>长×宽×高</td>
                                        </tr>
                                        <tr>
                                            <td>重量</td>
                                            <td th:text="${post.metadata.weight != null ? post.metadata.weight : '150'}">150</td>
                                            <td>kg</td>
                                            <td>净重</td>
                                        </tr>
                                        <tr>
                                            <td>工作压力</td>
                                            <td th:text="${post.metadata.pressure != null ? post.metadata.pressure : '1.6'}">1.6</td>
                                            <td>MPa</td>
                                            <td>最大工作压力</td>
                                        </tr>
                                        <tr>
                                            <td>工作温度</td>
                                            <td th:text="${post.metadata.temperature != null ? post.metadata.temperature : '-20~+80'}">-20~+80</td>
                                            <td>℃</td>
                                            <td>正常工作范围</td>
                                        </tr>
                                        <tr>
                                            <td>表面处理</td>
                                            <td th:text="${post.metadata.surface_treatment != null ? post.metadata.surface_treatment : '镀锌/喷塑'}">镀锌/喷塑</td>
                                            <td>-</td>
                                            <td>防腐处理</td>
                                        </tr>
                                        <tr>
                                            <td>包装方式</td>
                                            <td th:text="${post.metadata.packaging != null ? post.metadata.packaging : '木箱包装'}">木箱包装</td>
                                            <td>-</td>
                                            <td>出口标准包装</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 应用领域 -->
                    <div class="tab-content" id="applications">
                        <div class="content-wrapper">
                            <div class="applications-grid">
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-industry"></i>
                                    </div>
                                    <h4>工业制造</h4>
                                    <p>广泛应用于各种工业制造领域，提供可靠的机械解决方案</p>
                                </div>
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-cog"></i>
                                    </div>
                                    <h4>机械加工</h4>
                                    <p>精密机械加工应用，满足高精度加工要求</p>
                                </div>
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-car"></i>
                                    </div>
                                    <h4>汽车工业</h4>
                                    <p>汽车零部件制造和装配线应用</p>
                                </div>
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-oil-can"></i>
                                    </div>
                                    <h4>石油化工</h4>
                                    <p>石油化工设备和管道系统应用</p>
                                </div>
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-bolt"></i>
                                    </div>
                                    <h4>电力设备</h4>
                                    <p>电力设备制造和电网建设应用</p>
                                </div>
                                <div class="application-card">
                                    <div class="app-icon">
                                        <i class="fas fa-ship"></i>
                                    </div>
                                    <h4>船舶海工</h4>
                                    <p>船舶制造和海洋工程设备应用</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 认证资质 -->
                    <div class="tab-content" id="certifications">
                        <div class="content-wrapper">
                            <div class="certifications-grid">
                                <div class="cert-item">
                                    <div class="cert-icon">
                                        <i class="fas fa-certificate"></i>
                                    </div>
                                    <h4>ISO 9001:2015</h4>
                                    <p>质量管理体系认证</p>
                                </div>
                                <div class="cert-item">
                                    <div class="cert-icon">
                                        <i class="fas fa-leaf"></i>
                                    </div>
                                    <h4>ISO 14001:2015</h4>
                                    <p>环境管理体系认证</p>
                                </div>
                                <div class="cert-item">
                                    <div class="cert-icon">
                                        <i class="fas fa-shield-alt"></i>
                                    </div>
                                    <h4>CE认证</h4>
                                    <p>欧盟安全认证标志</p>
                                </div>
                                <div class="cert-item">
                                    <div class="cert-icon">
                                        <i class="fas fa-check-circle"></i>
                                    </div>
                                    <h4>SGS检测</h4>
                                    <p>第三方质量检测认证</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 相关产品推荐 -->
    <section class="related-products">
        <div class="container">
            <div class="section-header">
                <h2>相关产品推荐</h2>
                <p>您可能还感兴趣的其他产品</p>
            </div>
            <div class="products-slider">
                <div class="products-grid">
                    <th:block th:if="${relatedPosts != null && !relatedPosts.empty}">
                        <div class="product-card" th:each="relatedPost : ${relatedPosts}" th:if="${iterStat.index < 4}">
                            <div class="product-image">
                                <img th:if="${relatedPost.spec.cover != null}" th:src="${relatedPost.spec.cover}" th:alt="${relatedPost.spec.title}">
                                <img th:if="${relatedPost.spec.cover == null}" src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20product%20photo&image_size=landscape_4_3" th:alt="${relatedPost.spec.title}">
                                <div class="product-overlay">
                                    <a th:href="${relatedPost.status.href}" class="btn btn-outline">查看详情</a>
                                </div>
                            </div>
                            <div class="product-info">
                                <h3 th:text="${relatedPost.spec.title}">相关产品名称</h3>
                                <p th:text="${relatedPost.status.excerpt != null ? relatedPost.status.excerpt : '专业机械设备产品'}">相关产品描述</p>
                                <div class="product-meta">
                                    <span class="product-code">编号: MC-002</span>
                                    <span class="product-price">价格面议</span>
                                </div>
                            </div>
                        </div>
                    </th:block>
                    
                    <!-- 默认相关产品 -->
                    <th:block th:if="${relatedPosts == null || relatedPosts.empty}">
                        <div class="product-card">
                            <div class="product-image">
                                <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20valve%20machinery%20equipment%20product%20photo&image_size=landscape_4_3" alt="工业阀门">
                                <div class="product-overlay">
                                    <a href="#" class="btn btn-outline">查看详情</a>
                                </div>
                            </div>
                            <div class="product-info">
                                <h3>工业阀门</h3>
                                <p>高品质工业阀门，适用于各种工业管道系统</p>
                                <div class="product-meta">
                                    <span class="product-code">编号: MC-V001</span>
                                    <span class="product-price">价格面议</span>
                                </div>
                            </div>
                        </div>
                        <div class="product-card">
                            <div class="product-image">
                                <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20bearing%20machinery%20equipment%20product%20photo&image_size=landscape_4_3" alt="工业轴承">
                                <div class="product-overlay">
                                    <a href="#" class="btn btn-outline">查看详情</a>
                                </div>
                            </div>
                            <div class="product-info">
                                <h3>精密轴承</h3>
                                <p>高精度工业轴承，适用于各种机械传动系统</p>
                                <div class="product-meta">
                                    <span class="product-code">编号: MC-B001</span>
                                    <span class="product-price">价格面议</span>
                                </div>
                            </div>
                        </div>
                        <div class="product-card">
                            <div class="product-image">
                                <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20gear%20machinery%20equipment%20product%20photo&image_size=landscape_4_3" alt="传动齿轮">
                                <div class="product-overlay">
                                    <a href="#" class="btn btn-outline">查看详情</a>
                                </div>
                            </div>
                            <div class="product-info">
                                <h3>传动齿轮</h3>
                                <p>高强度传动齿轮，适用于各种动力传输应用</p>
                                <div class="product-meta">
                                    <span class="product-code">编号: MC-G001</span>
                                    <span class="product-price">价格面议</span>
                                </div>
                            </div>
                        </div>
                        <div class="product-card">
                            <div class="product-image">
                                <img src="https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20pump%20machinery%20equipment%20product%20photo&image_size=landscape_4_3" alt="工业泵">
                                <div class="product-overlay">
                                    <a href="#" class="btn btn-outline">查看详情</a>
                                </div>
                            </div>
                            <div class="product-info">
                                <h3>工业水泵</h3>
                                <p>高效工业水泵，适用于各种流体输送应用</p>
                                <div class="product-meta">
                                    <span class="product-code">编号: MC-P001</span>
                                    <span class="product-price">价格面议</span>
                                </div>
                            </div>
                        </div>
                    </th:block>
                </div>
            </div>
        </div>
    </section>

    <!-- 询价弹窗 -->
    <div id="inquiryModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>产品询价</h3>
                <button class="modal-close" onclick="closeInquiryModal()">&times;</button>
            </div>
            <div class="modal-body">
                <form id="productInquiryForm" onsubmit="submitInquiry(event)">
                    <div class="form-row">
                        <div class="form-group">
                            <label for="inquiry_name">姓名 *</label>
                            <input type="text" id="inquiry_name" name="name" required>
                        </div>
                        <div class="form-group">
                            <label for="inquiry_email">邮箱 *</label>
                            <input type="email" id="inquiry_email" name="email" required>
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="form-group">
                            <label for="inquiry_phone">电话 *</label>
                            <input type="tel" id="inquiry_phone" name="phone" required>
                        </div>
                        <div class="form-group">
                            <label for="inquiry_company">公司名称</label>
                            <input type="text" id="inquiry_company" name="company">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inquiry_product">感兴趣的产品</label>
                        <input type="text" id="inquiry_product" name="product_interest" th:value="${post.spec.title}" readonly>
                    </div>
                    <div class="form-row">
                        <div class="form-group">
                            <label for="inquiry_quantity">订购数量</label>
                            <input type="number" id="inquiry_quantity" name="quantity" placeholder="请输入数量">
                        </div>
                        <div class="form-group">
                            <label for="inquiry_delivery">期望交期</label>
                            <input type="date" id="inquiry_delivery" name="delivery_date">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inquiry_message">详细需求</label>
                        <textarea id="inquiry_message" name="message" rows="4" placeholder="请描述您的详细需求，包括技术要求、应用场景等..."></textarea>
                    </div>
                    <div class="form-actions">
                        <button type="button" class="btn btn-secondary" onclick="closeInquiryModal()">取消</button>
                        <button type="submit" class="btn btn-primary">提交询价</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script>
        // 图片画廊相关变量
        let currentImageIndex = 0;
        const galleryImages = [
            document.querySelector('#mainProductImage').src,
            'https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20side%20view%20professional%20product%20photo&image_size=square_hd',
            'https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20detail%20close%20up%20professional%20photo&image_size=square_hd',
            'https://trae-api-sg.mchost.guru/api/ide/v1/text_to_image?prompt=industrial%20machinery%20equipment%20application%20scene%20factory%20environment&image_size=square_hd'
        ];

        // 切换主图
        function changeMainImage(element, index) {
            const mainImage = document.getElementById('mainProductImage');
            mainImage.src = element.querySelector('img').src;
            currentImageIndex = index;
            
            // 更新缩略图激活状态
            document.querySelectorAll('.thumbnail-item').forEach(item => item.classList.remove('active'));
            element.classList.add('active');
        }

        // 上一张图片
        function previousImage() {
            currentImageIndex = currentImageIndex > 0 ? currentImageIndex - 1 : galleryImages.length - 1;
            updateMainImage();
        }

        // 下一张图片
        function nextImage() {
            currentImageIndex = currentImageIndex < galleryImages.length - 1 ? currentImageIndex + 1 : 0;
            updateMainImage();
        }

        // 更新主图
        function updateMainImage() {
            const mainImage = document.getElementById('mainProductImage');
            mainImage.src = galleryImages[currentImageIndex];
            
            // 更新缩略图激活状态
            document.querySelectorAll('.thumbnail-item').forEach((item, index) => {
                item.classList.toggle('active', index === currentImageIndex);
            });
        }

        // 标签页切换
        function switchTab(tabName) {
            // 移除所有激活状态
            document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
            document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
            
            // 激活当前标签
            event.target.classList.add('active');
            document.getElementById(tabName).classList.add('active');
        }

        // 打开询价弹窗
        function openInquiryModal() {
            document.getElementById('inquiryModal').style.display = 'block';
            document.body.style.overflow = 'hidden';
        }

        // 关闭询价弹窗
        function closeInquiryModal() {
            document.getElementById('inquiryModal').style.display = 'none';
            document.body.style.overflow = 'auto';
        }

        // 添加到收藏
        function addToFavorites() {
            // 这里可以添加收藏逻辑
            alert('已添加到收藏夹！');
        }

        // 提交询价表单
        function submitInquiry(event) {
            event.preventDefault();
            
            const formData = new FormData(event.target);
            const data = Object.fromEntries(formData);
            
            // 这里可以添加表单提交逻辑
            console.log('询价信息:', data);
            
            // 显示成功消息
            alert('询价信息已提交成功！我们将在24小时内与您联系。');
            
            // 关闭弹窗并重置表单
            closeInquiryModal();
            event.target.reset();
        }

        // 点击弹窗外部关闭
        window.onclick = function(event) {
            const modal = document.getElementById('inquiryModal');
            if (event.target === modal) {
                closeInquiryModal();
            }
        }

        // 键盘事件
        document.addEventListener('keydown', function(event) {
            if (event.key === 'ArrowLeft') {
                previousImage();
            } else if (event.key === 'ArrowRight') {
                nextImage();
            } else if (event.key === 'Escape') {
                closeInquiryModal();
            }
        });
    </script>

</th:block>
</body>
</html>